package com.weizai.carshop.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.weizai.carshop.common.enumeration.AppHttpCodeEnum;
import com.weizai.carshop.common.result.ResponseResult;
import com.weizai.carshop.model.dto.InsertAddressDto;
import com.weizai.carshop.model.entiity.AddressEntity;
import com.weizai.carshop.service.AddressService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/address")
@RequiredArgsConstructor
public class AddressController {

    private final AddressService addressService;

    /*
     * 查询地址列表
     * */

    @GetMapping()
    public ResponseResult queryAddressList() {
        Page<AddressEntity> page = addressService.lambdaQuery().page(new Page<>(1, 10));
        return ResponseResult.okResult(page.getRecords());
    }

    /*
    * 新增地址列表
    * */
    @PostMapping
    public ResponseResult addAddress(@RequestBody InsertAddressDto dto) {
        addressService.Insert(dto);
         return ResponseResult.okResult(AppHttpCodeEnum.SUCCESS);
    }

}
